	<include file='Common:header' />

		<!-- /section:basics/navbar.layout -->
		<div class="main-container" id="main-container">

			<!-- #section:basics/sidebar -->

	<include file='Common:left' />
			<!-- /section:basics/sidebar -->
			<div class="main-content">
				<div class="main-content-inner">
					<div class="page-content">
					
							<div class="row maintop">
							<div class="col-xs-12 col-sm-1">
<!-- 点击模态框（Modal） -->
								<button class="btn btn-xs btn-danger" data-toggle="modal" data-target="#myModal">
									<i class="ace-icon fa fa-bolt bigger-110"></i>
										添加会员组
								</button>
								
							</div>
							</div>
	

							<div class="row">
							    <div class="col-xs-12">
										<div>
										<form id="member_group_order" name="member_group_order" method="post" action="{:U('member_group_order')}" >
											<table width="100%" class="table table-striped table-bordered table-hover" id="dynamic-table">
												<thead>
													<tr>
													  <th width="10%">会员组ID</th>
													  <th width="22%">会员组名称</th>
													  <th width="34%">满足积分条件</th>
													  <th width="10%" style="border-right:#CCC solid 1px;">状态</th>
													  <th width="13%" style="border-right:#CCC solid 1px;">排序</th>
													  <th width="11%" style="border-right:#CCC solid 1px;">操作</th>
												  </tr>
												</thead>

												<tbody>
                                                
                                                <foreach name="member_group_list" item="v">
													<tr>
														<td height="28" >{$v.member_group_id}</td>
														<td>{$v.member_group_name}</td>
														<td>{$v.member_group_bomlimit} - {$v.member_group_toplimit} 积分</td>
														<td>
									<if condition='$v[member_group_open] eq 1'>
										<a class="red" href="javascript:;" onclick="return stateyes({$v.member_group_id});" title="已开启">
											<div id="zt{$v.member_group_id}"><button class="btn btn-minier btn-yellow">状态开启</button></div>
										</a>
									<else/>
										<a class="red" href="javascript:;" onclick="return stateyes({$v.member_group_id});" title="已禁用">
											<div id="zt{$v.member_group_id}"><button class="btn btn-minier btn-danger">状态禁用</button></div>
										</a>									</if>														</td>
														<td><input name="{$v.member_group_id}" value=" {$v.member_group_order}" class="list_order"/></td>
														<td>
									<div class="hidden-sm hidden-xs action-buttons">
										<a class="green"  href="javascript:;" onclick="return member_group_edit({$v.member_group_id});"  title="修改">
											<i class="ace-icon fa fa-pencil bigger-130"></i>
										</a>
										<a class="red" href="javascript:;" onclick="return del({$v.member_group_id});" title="删除">
											<i class="ace-icon fa fa-trash-o bigger-130"></i>
										</a>
									</div>
													</td>
													</tr>
                                                 </foreach>
                                                  <tr>
													  <td colspan="8" align="left"><button type="submit"  id="btnorder" class="btn btn-white btn-yellow btn-sm">排序</button></td>
												  </tr>

												</tbody>
										  </table>
										  </form>
							    		</div>
									</div>
								</div>

<include file='Common:header_nav' />

					</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->

<!-- 显示模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<form class="form-horizontal" name="member_group_runadd" id="member_group_runadd" method="post" action="__URL__/member_group_runadd">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" 
               aria-hidden="true">×
            </button>
            <h4 class="modal-title" id="myModalLabel">
               添加会员组
            </h4>
         </div>
         <div class="modal-body">
            
			
						<div class="row">
							<div class="col-xs-12">
																		
									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 会员组名称：  </label>
										<div class="col-sm-10">
											<input type="text" name="member_group_name" id="member_group_name" placeholder="输入会员组名称" class="col-xs-10 col-sm-5" />
										</div>
									</div>
                                    <div class="space-4"></div>

									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 积分条件：  </label>
										<div class="col-sm-10">

											<span class="input-icon">
												<input type="text" id="form-field-icon-1" name="member_group_bomlimit" placeholder="输入下限积分" />
												<i class="ace-icon fa fa-leaf blue"></i>
											</span>

											<span class="input-icon input-icon-right">
												<input type="text" id="form-field-icon-2" name="member_group_toplimit" placeholder="输入上限积分" />
												<i class="ace-icon fa fa-leaf green"></i>
											</span>

											<!-- /section:elements.form.input-icon -->
										</div>
									</div>
                                    <div class="space-4"></div>
									
									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 排序：  </label>
										<div class="col-sm-10">
											<input type="text" name="member_group_order" id="member_group_order" value="50" class="col-xs-10 col-sm-3" />
											<span class="lbl">&nbsp;&nbsp;<span class="red">*</span>从小到大排序</span>
										</div>
									</div>
                                    <div class="space-4"></div>

									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 是否开启： </label>
										<div class="col-sm-10" style="padding-top:5px;">
                                            <input name="member_group_open" id="member_group_open" value="1" class="ace ace-switch ace-switch-4 btn-flat" type="checkbox" />
											<span class="lbl">&nbsp;&nbsp;默认关闭</span>
										</div>
									</div>
                                    <div class="space-4"></div>
									
								</div>
							</div>
			
			
			
			
         </div>
         <div class="modal-footer">
		 	<button type="submit" class="btn btn-primary">
            	提交保存
            </button>
		 	<button class="btn btn-info" type="reset">
				重置
			</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">
				关闭
            </button>
         </div>
      </div><!-- /.modal-content -->
   </div><!-- /.modal-dialog -->
   </form>
</div><!-- /.modal -->


<!-- 显示模态框（Modal） -->
<div class="modal fade in" id="myModaledit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-backdrop fade in" id="gbbb" style="height: 100%;"></div>
<form class="form-horizontal" name="member_group_runedit" id="member_group_runedit" method="post" action="__URL__/member_group_runedit">
<input type="hidden" name="member_group_id" id="editmember_group_id" value="" />
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" id="gb"  data-dismiss="modal" 
               aria-hidden="true">×
            </button>
            <h4 class="modal-title" id="myModalLabel">
               修改用户组
            </h4>
         </div>
         <div class="modal-body">
            
			
						<div class="row">
							<div class="col-xs-12">
																		
									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 会员组名称：  </label>
										<div class="col-sm-10">
											<input type="text" name="member_group_name" id="editmember_group_name" value="" class="col-xs-10 col-sm-5" />
										</div>
									</div>
                                    <div class="space-4"></div>

									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 积分条件：  </label>
										<div class="col-sm-10">

											<span class="input-icon">
												<input type="text" id="editmember_group_bomlimit" name="member_group_bomlimit" placeholder="输入下限积分" />
												<i class="ace-icon fa fa-leaf blue"></i>
											</span>

											<span class="input-icon input-icon-right">
												<input type="text" id="editmember_group_toplimit" name="member_group_toplimit" placeholder="输入上限积分" />
												<i class="ace-icon fa fa-leaf green"></i>
											</span>

											<!-- /section:elements.form.input-icon -->
										</div>
									</div>
                                    <div class="space-4"></div>
									
									<div class="form-group">
										<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 排序：  </label>
										<div class="col-sm-10">
											<input type="text" name="member_group_order" id="editmember_group_order" value="50" class="col-xs-10 col-sm-3" />
											<span class="lbl">&nbsp;&nbsp;<span class="red">*</span>从小到大排序</span>
										</div>
									</div>
                                    <div class="space-4"></div>
									
								</div>
							</div>			
			
			
			
         </div>
         <div class="modal-footer">
		 	<button type="submit" class="btn btn-primary">
            	提交保存
            </button>
            <button type="button" class="btn btn-default"  id="gbb" >
				关闭
            </button>
         </div>
      </div><!-- /.modal-content -->
   </div><!-- /.modal-dialog -->
   </form>
</div><!-- /.modal -->



<script>
function del(id){
	layer.confirm('你确定要删除吗？', {icon: 3}, function(index){
	layer.close(index);
	window.location.href="__URL__/member_group_del/member_group_id/"+id+"";
	});
}

function stateyes(val){
		  $.post('{:U("member_group_state")}',
		  {x:val},
	function(data){
		if(data.status){
			if(data.info=='状态禁止'){
				var a='<button class="btn btn-minier btn-danger">状态禁用</button>'
				$('#zt'+val).html(a);
				layer.alert(data.info, {icon: 5});
				return false;
			}else{
				var b='<button class="btn btn-minier btn-yellow">状态开启</button>'
				$('#zt'+val).html(b);
				layer.alert(data.info, {icon: 6});
				return false;
			}
		}
	});
	return false;
}

//修改模态框状态
$(document).ready(function(){
	$("#myModaledit").hide();
	$("#gb").click(function(){
		$("#myModaledit").hide(200);
	});
	$("#gbb").click(function(){
		$("#myModaledit").hide(200);
	});
	$("#gbbb").click(function(){
		$("#myModaledit").hide(200);
	});
});

function member_group_edit(val){
		  $.post('{:U("member_group_edit")}',
		  {member_group_id:val},
	function(data){
		if(data.status==1){
				$(document).ready(function(){
					$("#myModaledit").show(300);
					$("#editmember_group_id").val(data.member_group_id);
					$("#editmember_group_name").val(data.member_group_name);
					$("#editmember_group_open").val(data.member_group_open);
					$("#editmember_group_toplimit").val(data.member_group_toplimit);
					$("#editmember_group_bomlimit").val(data.member_group_bomlimit);
					$("#editmember_group_order").val(data.member_group_order);
				});
			}else{

		}
	});
	return false;
}


$(function(){
	$('#member_group_runadd').ajaxForm({
		beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
		success: complete, // 这是提交后的方法
		dataType: 'json'
	});
	
	function checkForm(){
	
		if( '' == $.trim($('#member_group_name').val())){
			layer.alert('会员组名称不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('#member_group_name').focus(); 
			});
			return false;
		}
		
		if( '' == $.trim($('#form-field-icon-1').val())){
			layer.alert('会员组积分下限不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('#form-field-icon-1').focus(); 
			});
			return false;
		}
		
		if( '' == $.trim($('#form-field-icon-2').val())){
			layer.alert('会员组积分上限不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('#form-field-icon-2').focus(); 
			});
			return false;
		}
 }
	function complete(data){
		if(data.status==1){
			layer.alert(data.info, {icon: 6}, function(index){
 			layer.close(index);
			window.location.href=data.url;
			});
		}else{
			layer.alert(data.info, {icon: 6}, function(index){
 			layer.close(index);
			window.location.href=data.url;
			});
			return false;	
		}
	}
});


$(function(){
	$('#member_group_runedit').ajaxForm({
		beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
		success: complete, // 这是提交后的方法
		dataType: 'json'
	});
	
	function checkForm(){
		if( '' == $.trim($('#editmember_group_name').val())){
			layer.alert('会员组名称不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('#member_group_name').focus(); 
			});
			return false;
		}
		
		if( '' == $.trim($('#editmember_group_bomlimit').val())){
			layer.alert('会员组积分下限不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('#editmember_group_bomlimit').focus(); 
			});
			return false;
		}
		
		if( '' == $.trim($('#editmember_group_toplimit').val())){
			layer.alert('会员组积分上限不能为空', {icon: 6}, function(index){
 			layer.close(index);
			$('#editmember_group_toplimit').focus(); 
			});
			return false;
		}
	}
	function complete(data){
		if(data.status==1){
			layer.alert(data.info, {icon: 6}, function(index){
 			layer.close(index);
			window.location.href=data.url;
			});
		}else{
			layer.alert(data.info, {icon: 6}, function(index){
 			layer.close(index);
			window.location.href=data.url;
			});
			return false;	
		}
	}
 
});

//排序提交
$(function(){
	$('#member_group_order').ajaxForm({
		success: complete, // 这是提交后的方法
		dataType: 'json'
	});

	function complete(data){
		if(data.status==1){
			layer.alert(data.info, {icon: 6}, function(index){
 			layer.close(index);
			window.location.href=data.url;
			});
		}else{
			layer.alert(data.info, {icon: 6}, function(index){
 			layer.close(index);
			window.location.href=data.url;
			});
		}
	}
});

</script>
	<include file='Common:footer' />
    
		</div><!-- /.main-container -->
	</body>
</html>
